 <?php
       //get到id并输出productslist
    $action=@$_GET['action'];
	$classid= @$_GET["id"];
	$showorder= @$_GET['showorder'];
	
	//var_dump($classid); var_dump($showorder); echo '1'."<br>";
	
  if($showorder == ''){// var_dump($classid); var_dump($showorder);echo '2'."<br>";
	 // menu1
    if($action=="creat"){
	   
	   $showorder= 'show_order';
	   
	   //var_dump($classid); var_dump($showorder);echo '3'."<br>";
	   
	   listproducts($classid, $showorder);
	   
	}
   else{  
       $classid= 1;
	   
	  // var_dump($classid); var_dump($showorder);echo '4'."<br>";
	   
       listproducts($classid, $showorder);
	   
   }
   //排序
  }else{ //var_dump($classid); var_dump($showorder);echo '5'."<br>";
	  listproducts($classid, $showorder);
	  }
   
   
        //点击menu1超链接，输出响应productlist
  function listproducts($classid, $showorder){
			 global $aa;
			 
    ?> 
    
    <div id="sortproducts">
            <ul>
                <li><a href="?action=sort&id=<?php echo $classid; ?>&showorder=show_order">综合排序</a></li><li><a href="?action=sort&id=<?php echo $classid; ?>&showorder=sales_volume desc" onClick="function a9()">销量排序</a></li><li><a href="?action=sort&id=<?php echo $classid; ?>&showorder=price asc ">价格由低到高</a></li><li><a href="?action=sort&id=<?php echo $classid; ?>&showorder=price desc ">价格由高到低</a></li>
            </ul>
    </div>
    
    <div id="productsshow">
 
    <table id="listproducts" class="product">
            <tr>
                
        <?php
		   if($classid == 1) {
			   if($showorder == ''){   
			       $query = "select * from product_info where hot = $classid order by class_id";}
			   else{				   
				   $query = "select * from product_info where hot = $classid order by $showorder ";
				   }			   
			   }
		       else{ 
			       $query = "select * from product_info where class_id = '".$classid."' order by '".$showorder."' ";}
			$result = $aa->excu($query);
			$j=0;
			while ($product = mysqli_fetch_array($result, MYSQLI_ASSOC)){
				$j++;
		?>
                <td class="imgtd">
            <ul>
                <?php $img = $product['imgsrc'];  $img = explode("#", $img);  $num = count($img); 
				    for($i = 0; $i < $num; $i++){  
					    if ($i == 0){ ?>
                <li><a href=""><img src="<?php echo $img[$i]; ?>" /></a></li>
                <?php }else{ ?>
                    <li style=" display: none;"><img src="<?php echo $img[$i]; ?>" /></li>
                <?php } }?>
            </ul>
            
            <p class="productname"><?php echo $product['name']; ?></p>
            <p class="productintro"><small><?php echo $product['intro']; ?></small></a></p>
            <div style=" overflow: hidden;">
            <p class="span_dot" style=" width: <?php echo 25*$num; ?>px;">
			    <?php for($i = 0; $i < $num; $i++){ 
				    if ($i == 0){  ?>
                         <span class="spans onshowspan"></span>
                          <?php }else{ ?>
                             <span class="spans"></span>
                                <?php } }?>
            </p></div>
            
            <p class="productprice">￥<?php echo $product['price']; ?></p>
            
            <form method="post" action="" class="hide" id="form01">

            <a class="button" id="<?php echo $product['name']; ?>" href="productshow.php?id=<?php echo $product['id']; ?>">查看详情</a>
            <p id="addtocar" class="button gocar" name="<?php echo $product['id']; ?>">加入购物车</p><img src="img/head-logo.jpg" style=" display: none;" />
            </form>
                           
                </td>
             <?php
                 if($j%4 == 0){
			 ?>
                 </tr>
                 <tr>
            

        <?php
			      }
			}
		?>
        </table>

    </div>  
    
<?php
		}   //listproducts函数结束
?>